package com.ysm.freestyle.test.jetpack

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import com.ysm.freestyle.R
import com.ysm.freestyle.databinding.ActivityDataBindingBinding
import com.ysm.freestyle.model.User

class DataBindingActivity : AppCompatActivity() {
    val user = User()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = DataBindingUtil.setContentView<ActivityDataBindingBinding>(this,
            R.layout.activity_data_binding
        )
        user.name = "ysm"
        user.psw.set("123456")
        binding.user = user
        binding.tvName

        binding.lifecycleOwner = this
    }

    fun update(view: View){
        user.name = user.name + "->"
        user.psw.set(user.psw.get() + "->")
    }
}

